package com.tsll.controller;

import com.tsll.annotation.MyLog;
import com.tsll.entity.Staff;
import com.tsll.service.StafftransferService;
import com.tsll.vo.RejectionTransferVo;
import com.tsll.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/stafftransfer")
public class StafftransfeController {


    @Autowired
   private StafftransferService stafftranstferService;
    @Autowired
    private StafftransferService stafftranstferServiceimp;
    @MyLog(businessName = "调动员工")
    @RequestMapping ("/transfer")
    //定义一个名为transfer的方法，路径为/transfer
    public Result transfer(@RequestBody Staff stafftransfer) {
        //调用stafftranstferServiceimp.insertStaffTransfer方法，传入stafftransfer参数
        stafftranstferServiceimp.insertStaffTransfer(stafftransfer);
        //返回一个Result类型的结果，状态码为200，消息为"调动成功"，其他属性为null
        return new Result(200, "调动成功",null);
    }


    //查询所有调动员工
    @RequestMapping("/list/{current}/{pageSize}")
    public Result list(@PathVariable Integer current, @PathVariable Integer pageSize) {
        return stafftranstferService.checktransfer(current, pageSize);
    }
    @RequestMapping("/pasandnopas/{current}/{pageSize}")
    public Result pasandnopas(@PathVariable Integer current, @PathVariable Integer pageSize) {
        return stafftranstferService.transfer(current, pageSize);
    }

    //调动
    @RequestMapping("/adopt/{id}/{staffid}/{newdeptid}")
    public Result adopt(@PathVariable Integer id,@PathVariable Integer staffid, @PathVariable Integer newdeptid) {
        stafftranstferServiceimp.adopt(id,staffid,newdeptid);
        return new Result(200, "调动审核通过",null);
    }

    //驳回
    @RequestMapping("/reject")
    public Result reject(@RequestBody RejectionTransferVo rejectionTransferVo) {
        stafftranstferServiceimp.reject(rejectionTransferVo);
        return new Result(200, "驳回成功",null);
    }


    @RequestMapping("/deleteByPrimaryKey/{id}")
    public Result deleteByPrimaryKey(@PathVariable Integer id){
        return  stafftranstferServiceimp.deleteByPrimaryKey(id);
    }



}
